package com.wisezone.demo0216;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;

public class UDPClient {
	public static void main(String[] args) {
		try {
//			����DatagramSocket���󣬰󶨶˿�3456
			DatagramSocket sendSocket = new DatagramSocket(3456);
//			׼����Ҫ���͵����ݣ�����Ϊbyte[]
			String string = "Hello,I come form ICSS!";
			byte[] databyte = new byte[100];
			databyte = string.getBytes();
//			�������ݱ�����װ��Ҫ���͵����ݣ����ݳ��ȣ���������ַ���Լ��������˿�Ϊ5000
			DatagramPacket sendPacket = new DatagramPacket(databyte,
					string.length(), InetAddress.getByName("127.0.0.1"), 5000);
//			ʹ��DatagramSocket�������ݱ�sendPacket���͵�������
			sendSocket.send(sendPacket);
			System.out.println("��������:" + string);
		} catch (SocketException e) {
			System.out.println(e);
		} catch (IOException ioe) {
			System.out.println(ioe);
		}
	}
}
